<!DOCTYPE html>
<html lang="zh" xmlns:th="https://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('菜单列表')"/>
</head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title ibox-title-gray dashboard-header">
                    <h5>导航菜单</h5>
                </div>
                <div class="ibox-content">
                    <div class="nav-tabs-custom">
                        <ul class="nav nav-tabs">
                            <!--<li class="active"><a href="#user_info" data-toggle="tab" aria-expanded="true">基本资料</a></li>
                            <li><a href="#modify_password" data-toggle="tab" aria-expanded="false">修改密码</a></li>-->
                            <li th:each="func,funcStat:${funcList}"  th:class="${funcStat.index==0}? 'active' : ''">
                                <a th:href="@{#func_}+${func.id}" data-toggle="tab" th:attr="aria-expanded=${funcStat.first}" th:text="${func.funcName}"></a>
                            </li>
                        </ul>
                        <div class="tab-content">
                            <div th:each="func,funcStat:${funcList}" class="col-sm-12 select-table table-striped" th:classappend="${funcStat.index==0}? 'tab-pane active' : 'tab-pane'"
                                 th:attr="id=@{func_}+${func.id}">
                                [[${func.funcName}]]=========================
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-tree-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var datas = [[${@dict.getType('sys_show_hide')}]];
    var prefix = ctx + "king/func";

    $(function () {
        var options = {
            code: "funcId",
            parentCode: "parentId",
            uniqueId: "funcId",
            expandAll: false,
            expandFirst: true,
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            modalName: "菜单",
            columns: [{
                field: 'selectItem',
                radio: true
            },
                {
                    title: '菜单名称',
                    field: 'funcName',
                    width: '20%',
                    formatter: function (value, row, index) {
                        if ($.common.isEmpty(row.icon)) {
                            return row.funcName;
                        } else {
                            return '<i class="' + row.icon + '"></i> <span class="nav-label">' + row.funcName + '</span>';
                        }
                    }
                },
                {
                    field: 'orderNum',
                    title: '排序',
                    width: '10%',
                    align: "left"
                },
                {
                    field: 'url',
                    title: '请求地址',
                    width: '15%',
                    align: "left"
                },
                {
                    title: '类型',
                    field: 'funcType',
                    width: '10%',
                    align: "left",
                    formatter: function (value, item, index) {
                        if (item.funcType == 'M') {
                            return '<span class="label label-success">目录</span>';
                        } else if (item.funcType == 'C') {
                            return '<span class="label label-primary">菜单</span>';
                        } else if (item.funcType == 'F') {
                            return '<span class="label label-warning">按钮</span>';
                        }
                    }
                },
                {
                    field: 'visible',
                    title: '可见',
                    width: '10%',
                    align: "left",
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, row.visible);
                    }
                },
                {
                    field: 'perms',
                    title: '权限标识',
                    width: '15%',
                    align: "left",
                },
                {
                    title: '操作',
                    width: '20%',
                    align: "left",
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
                        //actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="$.operate.add(\'' + row.id + '\')"><i class="fa fa-plus"></i> 新增</a> ');
                        actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i> 删除</a>')
                        return actions.join('');
                    }
                }]
        };
        $.treeTable.init(options);
    });
</script>
</body>
</html>